package com.awei.study.design.structure.flyWeight;

import java.util.HashMap;

/**
 * @Author liweilong
 * @Date 2024/8/9 15:34
 */
public class BoxFactory {
    private static HashMap<String, FlyWeight.AbstractBox> map;

    private BoxFactory() {
        map = new HashMap<>();
        FlyWeight.AbstractBox ibox = new FlyWeight.IBox();
        FlyWeight.AbstractBox lBox = new FlyWeight.LBox();
        FlyWeight.AbstractBox oBox = new FlyWeight.OBox();
        map.put("i",ibox);
        map.put("l",lBox);
        map.put("o",oBox);
    }

    public static final BoxFactory getInstance() {
        return BoxFactory.SingletonHolder.INSTANCE;
    }

    private static class SingletonHolder {
        private static final BoxFactory INSTANCE = new BoxFactory();
    }
}
